package hu.donpedropizza;

import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

public class Order extends Activity {

	ImageView imView1;
	ImageView imView2;
	String imageUrl1 = "http://donpedropizza.hu/images/cache/2/5/252s110c2490.00i.jpg";
	String imageUrl2 = "http://donpedropizza.hu/images/cache/2/5/251s110c1990.00i.jpg";

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.order);
		imView1 = (ImageView) findViewById(R.id.imview1);
		imView1.setImageBitmap(downloadImage(imageUrl1));
		imView2 = (ImageView) findViewById(R.id.imview2);
		imView2.setImageBitmap(downloadImage(imageUrl2));
	}


	public void back(View view) {
		this.finish();
	}

	public void menu(View view) {
		Intent intent = new Intent(Order.this, Menu.class);
		Order.this.startActivity(intent);
	}
	
	public static Bitmap downloadImage(String url) {
		URL myFileUrl = null;
		try {
			myFileUrl = new URL(url);
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
		try {
			HttpURLConnection conn = (HttpURLConnection) myFileUrl
					.openConnection();
			conn.setDoInput(true);
			conn.connect();
			InputStream is = conn.getInputStream();

			return BitmapFactory.decodeStream(is);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
}
